import { getListInfo, Article } from "./type";
import service from "@/utils/request";
import { AxiosPromise } from "axios";

const { resourceService } = service;
/**
 * 管理员获取列表
 *
 */
export function getResource(data: getListInfo): AxiosPromise<any> {
  return resourceService({
    url: "/resource/posting/managerGetList",
    method: "get",
    params: data,
  });
}

/**
 * 管理员修改
 */
export function updatainfo(data: any): AxiosPromise<any> {
  return resourceService({
    url: "/resource/posting/updateByManager",
    method: "put",
    data: data,
  });
}

/**
 *
 * @param ids 删除
 * @returns
 */

export function deleteAdmin(ids: number[]): AxiosPromise<any> {
  return resourceService({
    url: "/resource/posting/deleteByManager/" + ids.join(","),
    method: "delete",
  });
}

/**
 * 管理员获取详情
 */
export function getDetail(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/posting/managerGetById/" + id,
    method: "get",
  });
}

/**
 * 管理员审核
 */

export function examinePass(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/posting/audit/" + id,
    method: "put",
  });
}

export function examineNotPass(id: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/posting/auditNotPass/" + id,
    method: "put",
  });
}

/**
 * 获取可见范围
 */
export function getVisible(): AxiosPromise<any> {
  return resourceService({
    url: "/resource/visibleType",
    method: "get",
  });
}

/**
 *
 * 获取一级分类
 * @returns
 */
export function getType1(): AxiosPromise<any> {
  return resourceService({
    url: "/resource/category/selectLevel1",
    method: "get",
  });
}

/**
 * 获取二级分类
 */
export function getType2(parentId: number): AxiosPromise<any> {
  return resourceService({
    url: "/resource/category/selectLevel1/" + parentId,
    method: "get",
  });
}
